package com.vaadin.lab8;

import com.vaadin.Application;
import com.vaadin.data.Item;
import com.vaadin.data.Container.Filter;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.util.BeanItemContainer;
import com.vaadin.data.util.filter.Compare;
import com.vaadin.lab7.Product;
import com.vaadin.ui.DateField;
import com.vaadin.ui.PopupDateField;
import com.vaadin.ui.Table;
import com.vaadin.ui.Window;

@SuppressWarnings("serial")
public class Lab extends Application {

    @Override
    public void init() {
        Window mainWindow = new Window("Lab");
        setMainWindow(mainWindow);
        
        final BeanItemContainer<Product> c = new ContainerHelper().createProductContainer();
        Table table = new Table("t", c);
        getMainWindow().addComponent(table);
        
        final PopupDateField dateField = new PopupDateField();
        getMainWindow().addComponent(dateField);
        dateField.setImmediate(true);
        dateField.setResolution(DateField.RESOLUTION_DAY);
        
        dateField.addListener(new Property.ValueChangeListener() {
			
			@Override
			public void valueChange(ValueChangeEvent event) {
				Filter filter = new Compare.Equal("available",dateField.getValue());
				c.addContainerFilter(filter);
			}
		});
        
        
       
    }

}
